package yxy.cherry.battle.module.affix.skill;

import yxy.cherry.battle.Battle;
import yxy.cherry.battle.Fighter;
import yxy.cherry.battle.module.affix.AffixFactory.SkillTypeEnum;
import yxy.cherry.battle.module.affix.Skill;
import yxy.cherry.battle.module.affix.SkillType;
import yxy.cherry.battle.module.record.stream.RecordStream_24_怒气变化;
import yxy.cherry.data.bean.skill;

/**
 * 怒气抢夺
 * @author James
 * @Date 2022.4.2
 * */
@SkillType(Type = SkillTypeEnum.怒气抢夺)
public class Affix_21_怒气抢夺 extends Skill {
	private int getAngerNumber(){return getParam(0);}

	public Affix_21_怒气抢夺(Fighter actor, skill skilldata, int probability, int[] params) {
		super(actor, skilldata, probability, params);
	}

	@Override
	public boolean exec(Fighter actor, Fighter target) {
		int angerNumber = getAngerNumber();
		int targetAngerNumber = target.getAnger();
		int finalAddAnger = Math.min(angerNumber,targetAngerNumber);
		int targetAngerNow = targetAngerNumber - finalAddAnger;

		if (finalAddAnger == 0) {
			return false;
		}
		actor.add怒气(finalAddAnger);
		target.initAnger(targetAngerNow);
		getAffixContext().add怒气变动武将(actor);
		getAffixContext().add怒气变动武将(target);

		// 流脚本
		getRecord().stream(new RecordStream_24_怒气变化(actor, finalAddAnger)).record();
		getRecord().stream(new RecordStream_24_怒气变化(target, -finalAddAnger)).record();

		// 输出
		Battle.battleLogger(6,"怒气抢夺：抢夺者："+actor.getName()+"目标："+target.getName()+"目标怒气值："+targetAngerNumber+"抢夺的怒气值："+finalAddAnger);
		return true;
	}
}